#include "mobilestoragelistdelegate.h"

#include <QPainter>
//暂时
#include <QDebug>

#include "mobilestoragelistview.h"

const int ICON_MODE_ITEM_WIDTH = 96;
const int ICON_MODE_ITEM_HEIGHT = 96;
const int LIST_MODE_ITEM_HEIGHT = 52;

MobileStorageListDelegate::MobileStorageListDelegate(QAbstractItemView *parent) : KListViewDelegate(parent) {}

MobileStorageListDelegate::~MobileStorageListDelegate() {}

QSize MobileStorageListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
//    Q_UNUSED(index);
    auto *listView = qobject_cast<const MobileStorageListView *>(option.widget);

    if (listView->viewMode() == QListView::IconMode) {
        return QSize(ICON_MODE_ITEM_WIDTH, ICON_MODE_ITEM_HEIGHT);
    } else {
        auto size = KListViewDelegate::sizeHint(option, index);
        return QSize(size.width(), LIST_MODE_ITEM_HEIGHT);
    }
}
